package sudroid.net;

import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Map;
import sudroid.AssertUtil;
import sudroid.LogUtils;
import sudroid.android.FileUtil;
import sudroid.android.graphics.BitmapUtils;
import sudroid.security.MD5;

public class CacheUtil
{
  public static final String NOTHING = "nothing";
  private static HttpUtil httpUtil;
  private static ResponseHandler pictureHandler = new CacheUtil.1();

  public static boolean cleanPictureCache(String paramString1, String paramString2)
  {
    AssertUtil.checkNull(paramString1);
    AssertUtil.checkNull(paramString2);
    return FileUtil.deleteDependon(generatedCacheFilePath(paramString1, paramString2));
  }

  private static String generatedCacheFilePath(String paramString1, String paramString2)
  {
    String str1 = MD5.hexdigest(paramString1);
    String str2 = String.valueOf(paramString2);
    return str2 + "/" + str1;
  }

  private static HttpUtil getHttpUtil()
  {
    if (httpUtil == null)
      httpUtil = HttpUtil.getInstance();
    return httpUtil;
  }

  public static String getPicture(String paramString1, String paramString2)
  {
    return getPicture(paramString1, null, paramString2);
  }

  public static String getPicture(String paramString1, Map<String, String> paramMap, String paramString2)
  {
    return getPicture(paramString1, paramMap, paramString2, 0);
  }

  private static String getPicture(String paramString1, Map<String, String> paramMap, String paramString2, boolean paramBoolean)
  {
    AssertUtil.checkNull(paramString1);
    AssertUtil.checkNull(paramString2);
    String str1 = generatedCacheFilePath(paramString1, paramString2);
    String str2;
    if ((FileUtil.doesExisted(str1)) && (!paramBoolean) && (BitmapUtils.isImage(str1, null)))
      str2 = str1;
    while (true)
    {
      return str2;
      try
      {
        HttpResponse localHttpResponse = getHttpUtil().get(paramString1, paramMap);
        ResponseHandler localResponseHandler = pictureHandler;
        localHttpResponse.setHandler(localResponseHandler);
        Object[] arrayOfObject = new Object[1];
        FileOutputStream localFileOutputStream = FileUtil.getEmptyFileOutputStream(str1);
        arrayOfObject[0] = localFileOutputStream;
        boolean bool = localHttpResponse.process(arrayOfObject);
        str2 = str1;
      }
      catch (IOException localIOException)
      {
        LogUtils.e(localIOException);
        str2 = null;
      }
      catch (Not2xxException localNot2xxException)
      {
        while (true)
          LogUtils.e(localNot2xxException);
      }
    }
  }

  public static String getPictureWithoutCache(String paramString1, String paramString2)
  {
    return getPictureWithoutCache(paramString1, null, paramString2);
  }

  public static String getPictureWithoutCache(String paramString1, Map<String, String> paramMap, String paramString2)
  {
    return getPicture(paramString1, paramMap, paramString2, 1);
  }
}

/* Location:           D:\Program Files\eclipse\apktool-r01-3\新浪微博\classes.dex.dex2jar.jar
 * Qualified Name:     sudroid.net.CacheUtil
 * JD-Core Version:    0.6.0
 */